package com.atguigu.java.ai.langchain4j.controller;

import com.atguigu.java.ai.langchain4j.assistant.RenHeYiYuanAgent;
import com.atguigu.java.ai.langchain4j.bean.ChatFrom;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@Tag(name = "人和助手")
@RestController
@RequestMapping("/renhe")
public class RenHeController {

    @Autowired
    private RenHeYiYuanAgent renHeYiYuanAgent;

    @Operation(summary = "人和助手对话")
    @PostMapping(value = "/chat",produces = "text/stream;charset=UTF-8")
    public Flux<String> chat(@RequestBody ChatFrom chatFrom) {
        return renHeYiYuanAgent.chat(chatFrom.getMemoryId(), chatFrom.getMessage());
    }


}
